#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/wait.h>

int main(){
  //1.以读方式打开管道文件读取数据
  int fd = open("PIPE",O_RDONLY);
  char buf[128];
  while(1){
    ssize_t ret = read(fd,buf,sizeof(buf));
    buf[ret] = 0;
    if(ret > 0){
      printf("i recieve the message:%s\n",buf);
    }
    else if(ret == 0) {
      printf("server qut!\n");
      break;
    }
    else{
      perror("read from PIPE error!\n");
      break;
    }
  }
  return 0;
}
